/*
 * @Author: your name
 * @Date: 2022-02-15 21:19:06
 * @LastEditTime: 2022-02-16 07:39:00
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3.2\src\utils\filters.js
 */
const dayjs = require('dayjs')

const filetrTimes = (val, format = 'YYYY-MM-DD') => {
  if (!isNull(val)) {
    val = parseInt(val) * 1000
    return dayjs(val).format(format)
  } else {
    return '--'
  }
}

export const isNull = (data) => {
  if (!data) return true
  if (JSON.stringify(data) === '{}') return true
  if (JSON.stringify(data) === '[]') return true
}

export default app => {
  app.config.globalProperties.$filters = {
    filetrTimes
  }
}
